package com.lrkj.system.service.impl;

import java.util.List;
import com.lrkj.common.utils.DateUtils;
import com.lrkj.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.lrkj.system.mapper.SysPayConfigMapper;
import com.lrkj.system.domain.SysPayConfig;
import com.lrkj.system.service.ISysPayConfigService;

/**
 * 支付配置Service业务层处理
 *
 * @author yajun_ren
 * @date 2022-08-30
 */
@Service("sysPayConfigService")
public class SysPayConfigServiceImpl implements ISysPayConfigService
{
    @Autowired
    private SysPayConfigMapper sysPayConfigMapper;

    /**
     * 查询支付配置
     *
     * @param id 支付配置ID
     * @return 支付配置
     */
    @Override
    public SysPayConfig selectSysPayConfigById(String id)
    {
        return sysPayConfigMapper.selectSysPayConfigById(id);
    }

    /**
     * 查询支付配置列表
     *
     * @param sysPayConfig 支付配置
     * @return 支付配置
     */
    @Override
    public List<SysPayConfig> selectSysPayConfigList(SysPayConfig sysPayConfig)
    {
        return sysPayConfigMapper.selectSysPayConfigList(sysPayConfig);
    }

    /**
     * 新增支付配置
     *
     * @param sysPayConfig 支付配置
     * @return 结果
     */
    @Override
    @CacheEvict(value = "system.payConfig.typeConfig", allEntries = true)
    public int insertSysPayConfig(SysPayConfig sysPayConfig)
    {
        sysPayConfig.setCreateTime(DateUtils.getNowDate());
        sysPayConfig.setId(IdUtils.simpleUUID());
        return sysPayConfigMapper.insertSysPayConfig(sysPayConfig);
    }

    /**
     * 修改支付配置
     *
     * @param sysPayConfig 支付配置
     * @return 结果
     */
    @Override
    @CacheEvict(value = "system.payConfig.typeConfig", allEntries = true)
    public int updateSysPayConfig(SysPayConfig sysPayConfig)
    {
        sysPayConfig.setUpdateTime(DateUtils.getNowDate());
        return sysPayConfigMapper.updateSysPayConfig(sysPayConfig);
    }

    /**
     * 批量删除支付配置
     *
     * @param ids 需要删除的支付配置ID
     * @return 结果
     */
    @Override
    @CacheEvict(value = "system.payConfig.typeConfig", allEntries = true)
    public int deleteSysPayConfigByIds(String[] ids)
    {
        return sysPayConfigMapper.deleteSysPayConfigByIds(ids);
    }

    /**
     * 删除支付配置信息
     *
     * @param id 支付配置ID
     * @return 结果
     */
    @Override
    @CacheEvict(value = "system.payConfig.typeConfig", allEntries = true)
    public int deleteSysPayConfigById(String id)
    {
        return sysPayConfigMapper.deleteSysPayConfigById(id);
    }

    @Override
    @Cacheable(value = "system.payConfig.typeConfig", key = "#type")
    public SysPayConfig getConfig(String type) {
        return sysPayConfigMapper.getConfig(type);
    }

    /**
     * 批量新增支付配置信息
     *
     * @param sysPayConfigs 支付配置对象
     */
    public int batchAddData(List<SysPayConfig> sysPayConfigs)
    {
           return sysPayConfigMapper.batchAddData(sysPayConfigs);
    }



}
